package o;

import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.a;

public final class afx implements agc {
    private int ʻ;
    private int ʼ;
    private long ʽ;
    private final anc ˊ = new anc(new byte[18]);
    private long ˊॱ;
    private String ˋ;
    private aef ˎ;
    private int ˏ = 0;
    private final String ॱ;
    private int ॱॱ;
    private Format ᐝ;

    public afx(String str) {
        this.ॱ = str;
    }

    public void ˏ() {
        this.ˏ = 0;
        this.ʼ = 0;
        this.ʻ = 0;
    }

    public void ˏ(ady o_ady, a aVar) {
        aVar.ˊ();
        this.ˋ = aVar.ˎ();
        this.ˎ = o_ady.ˊ(aVar.ˏ(), 1);
    }

    public void ˋ(long j, int i) {
        this.ˊॱ = j;
    }

    public void ˊ(anc o_anc) {
        while (o_anc.ˊ() > 0) {
            switch (this.ˏ) {
                case 0:
                    if (!ˏ(o_anc)) {
                        break;
                    }
                    this.ˏ = 1;
                    break;
                case 1:
                    if (!ˋ(o_anc, this.ˊ.ˏ, 18)) {
                        break;
                    }
                    ˎ();
                    this.ˊ.ˋ(0);
                    this.ˎ.ˎ(this.ˊ, 18);
                    this.ˏ = 2;
                    break;
                case 2:
                    int min = Math.min(o_anc.ˊ(), this.ॱॱ - this.ʼ);
                    this.ˎ.ˎ(o_anc, min);
                    this.ʼ = min + this.ʼ;
                    if (this.ʼ != this.ॱॱ) {
                        break;
                    }
                    this.ˎ.ˋ(this.ˊॱ, 1, this.ॱॱ, 0, null);
                    this.ˊॱ += this.ʽ;
                    this.ˏ = 0;
                    break;
                default:
                    throw new IllegalStateException();
            }
        }
    }

    public void ˋ() {
    }

    private boolean ˋ(anc o_anc, byte[] bArr, int i) {
        int min = Math.min(o_anc.ˊ(), i - this.ʼ);
        o_anc.ˎ(bArr, this.ʼ, min);
        this.ʼ = min + this.ʼ;
        return this.ʼ == i;
    }

    private boolean ˏ(anc o_anc) {
        while (o_anc.ˊ() > 0) {
            this.ʻ <<= 8;
            this.ʻ |= o_anc.ʽ();
            if (acn.ॱ(this.ʻ)) {
                this.ˊ.ˏ[0] = (byte) ((this.ʻ >> 24) & 255);
                this.ˊ.ˏ[1] = (byte) ((this.ʻ >> 16) & 255);
                this.ˊ.ˏ[2] = (byte) ((this.ʻ >> 8) & 255);
                this.ˊ.ˏ[3] = (byte) (this.ʻ & 255);
                this.ʼ = 4;
                this.ʻ = 0;
                return true;
            }
        }
        return false;
    }

    private void ˎ() {
        byte[] bArr = this.ˊ.ˏ;
        if (this.ᐝ == null) {
            this.ᐝ = acn.ˋ(bArr, this.ˋ, this.ॱ, null);
            this.ˎ.ˎ(this.ᐝ);
        }
        this.ॱॱ = acn.ˎ(bArr);
        this.ʽ = (long) ((int) ((((long) acn.ˊ(bArr)) * 1000000) / ((long) this.ᐝ.ʼॱ)));
    }
}
